"""
图片生成数据模式
"""

from typing import Optional, Dict, Any
from datetime import datetime
from pydantic import BaseModel, Field


class ImageGenerationBase(BaseModel):
    """图片生成基础模式"""
    prompt: str = Field(..., description="图片生成提示词")
    size: Optional[str] = Field("1024x1024", description="图片尺寸")
    quality: Optional[str] = Field("standard", description="图片质量")
    style: Optional[str] = Field(None, description="图片风格")
    n: Optional[int] = Field(1, description="生成图片数量", ge=1, le=4)


class ImageGenerationRequest(ImageGenerationBase):
    """图片生成请求模式"""
    conversation_id: int = Field(..., description="对话ID")
    original_image_id: Optional[int] = Field(None, description="原始图片ID(用于调整)")
    model_provider: Optional[str] = Field("openai", description="模型提供商")
    model_name: Optional[str] = Field("dall-e-3", description="模型名称")


class ImageAdjustmentRequest(BaseModel):
    """图片调整请求模式"""
    conversation_id: int = Field(..., description="对话ID")
    original_image_id: int = Field(..., description="要调整的原始图片ID")
    adjustment_prompt: str = Field(..., description="调整描述")
    size: Optional[str] = Field(None, description="图片尺寸")
    quality: Optional[str] = Field(None, description="图片质量")
    style: Optional[str] = Field(None, description="图片风格")


class ImageGenerationResponse(BaseModel):
    """图片生成响应模式"""
    id: int
    conversation_id: int
    user_id: int
    prompt: str
    original_image_id: Optional[int] = None
    image_url: str
    image_path: Optional[str] = None
    model_provider: Optional[str] = None
    model_name: Optional[str] = None
    size: Optional[str] = None
    quality: Optional[str] = None
    style: Optional[str] = None
    image_metadata: Optional[Dict[str, Any]] = None
    created_at: datetime
    
    class Config:
        from_attributes = True


class ImageGenerationListResponse(BaseModel):
    """图片生成列表响应模式"""
    images: list[ImageGenerationResponse]
    total: int
    conversation_id: int

